package com.sunshine.cloud.controller;

import com.sunshine.cloud.bean.Person;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * FirstController class
 *
 * @author WeiHong
 * @date 2018/11/9
 */
@RestController
public class FirstController {

    @RequestMapping(value = "/findPerson/{personId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public Person findPerson (@PathVariable("personId") Integer personId, HttpServletRequest request){
        Person person = new Person(personId, "Liming", 22);
        person.setMessage(request.getRequestURL().toString());
        return person;
    }
}
